home *** CD-ROM | disk | FTP | other *** search
/ HAM Radio 1997 / HAM Radio 1997.iso / vcls / moden / adport.int < prev    next >
Text File  |  1996-04-08  |  26KB  |  688 lines

  1. {Conditional defines that may affect this unit}
  2. {$I AWDEFINE.INC}
  3.  
  4. {Required options}
  5. {$G+,X+,F+}
  6. {$C MOVEABLE,DEMANDLOAD,DISCARDABLE}
  7.  
  8. {*********************************************************}
  9. {*                    ADPORT.PAS 1.01                    *}
  10. {*        Copyright (c) TurboPower Software 1995         *}
  11. {*                 All rights reserved.                  *}
  12. {*********************************************************}
  13.  
  14. unit AdPort;
  15.   {-Delphi serial port component}
  16.  
  17. interface
  18.  
  19. uses
  20.   {!!.01 modified}
  21.   {-----RTL}
  22.   WinTypes,
  23.   WinProcs,
  24.   SysUtils,
  25.   Classes,
  26.   Messages,
  27.   Controls,
  28.   DsgnIntf,
  29.   Forms,
  30.   {-----APD}
  31.   OoMisc,
  32.   {$IFNDEF UseAPWDLL}
  33.   AwUser,
  34.   {$ENDIF}
  35.   AwComm,
  36.   AwFossil,
  37.   AdMisc,
  38.   AdExcept,
  39.   AdPEdit0;
  40.  
  41. {$IFDEF UseAPWDLL}
  42. {$I AWPORT.PA0}       {Data/procedure/function declarations}
  43. {$I AWUSER.PA0}       {Procedure/function declarations}
  44. {$ENDIF}
  45.  
  46. type
  47.   {Parity type}
  48.   TParity = (pNone, pOdd, pEven, pMark, pSpace);
  49.  
  50.   {Activation procedure type}
  51.   TActivationProcedure = procedure;
  52.  
  53.   {Device layer types}
  54.   TDeviceLayer = (dlNone, dlComm, dlFossil, dlOther);
  55.  
  56.   {Baud type}
  57.   TBaudRate = LongInt;
  58.  
  59.   {Hardware flow control types}
  60.   THWFlowOptions = (
  61.     hwfUseDTR,      {Use DTR for receive flow control}
  62.     hwfUseRTS,      {Use RTS for receive flow control}
  63.     hwfRequireDSR,  {Require DSR before transmittting}
  64.     hwfRequireCTS); {Require CTS before transmittting}
  65.   THWFlowOptionSet = set of THWFlowOptions;
  66.  
  67.   {Software flow control types}
  68.   TSWFlowOptions = (swfNone, swfReceive, swfTransmit, swfBoth);
  69.  
  70.   {For reporting flow states, note: no rcv hardware flow status is provided}
  71.   TFlowControlState = (fcOff,        {No flow control is in use}
  72.                        fcOn,         {Transmit blocked}
  73.                        fcDsrHold,    {Transmit blocked by low DSR}
  74.                        fcCtsHold,    {Transmit blocked by low CTS}
  75.                        fcDcdHold,    {Transmit blocked by low DCD}
  76.                        fcXOutHold,   {Transmit blocked by Xoff}
  77.                        fcXInHold,    {Receive blocked by Xoff}
  78.                        fcXBothHold); {Both are blocked by Xoff}
  79.  
  80.   {Tracing/logging states}
  81.   TTraceLogState = (tlOff, tlOn, tlDump, tlAppend, tlClear, tlPause);
  82.  
  83.   {General trigger event handler}
  84.   TTriggerEvent = procedure(CP : TObject;
  85.                             Msg, TriggerHandle, Data : Word) of object;
  86.  
  87.   {Specific trigger event handlers}
  88.   TTriggerAvailEvent = procedure(CP : TObject; Count : Word) of object;
  89.   TTriggerDataEvent = procedure(CP : TObject; TriggerHandle : Word) of object;
  90.   TTriggerStatusEvent = procedure(CP : TObject;
  91.                                   TriggerHandle : Word) of object;
  92.   TTriggerTimerEvent = procedure(CP : TObject; TriggerHandle : Word) of object;
  93.  
  94.   {Status event handlers}
  95.   TTriggerLineErrorEvent   = procedure(CP : TObject;
  96.                                        Error : Word;
  97.                                        LineBreak : Boolean) of object;
  98.  
  99.   {WaitChar event handler}
  100.   TWaitCharEVent = procedure(CP : TObject; C : Char) of object;
  101.  
  102.  
  103.   {Port open/close callbacks}
  104.   TPortCallback = procedure(CP : TObject; Opening : Boolean) of object;
  105.  
  106.   {Dispatcher modes}
  107.   TDispatcherMode = (
  108.     dNone,               {Failed to enable dispatcher}
  109.     dTimer,              {Use the timer only}
  110.     dCommEvents,         {Use 3.1 style comm events and a timer}
  111.     dAuto);
  112.  
  113.   {For keeping track of port users}                                    {!!.01}
  114.   PUserListEntry = ^TUserListEntry;                                    {!!.01}
  115.   TUserListEntry = record                                              {!!.01}
  116.     Handle     : THandle;                                              {!!.01}
  117.     OpenClose  : TPortCallback;                                        {!!.01}
  118.   end;                                                                 {!!.01}
  119.  
  120.   {$I OOMISC.PA2}        {Contains types for OOPORT/ADPORT}
  121.  
  122. const
  123.   {Message values, duplicated from OOMISC}
  124.   APW_TRIGGERAVAIL   = OOMISC.apw_TriggerAvail;
  125.   APW_TRIGGERDATA    = OOMISC.apw_TriggerData;
  126.   APW_TRIGGERTIMER   = OOMISC.apw_TriggerTimer;
  127.   APW_TRIGGERSTATUS  = OOMISC.apw_TriggerStatus;
  128.  
  129.   {Modem status trigger options, duplicated from OOMISC}
  130.   msCTSDelta   = $0010;
  131.   msDSRDelta   = $0020;
  132.   msRingDelta  = $0004;
  133.   msDCDDelta   = $0080;
  134.  
  135.   {Line status trigger options, duplicated from OOMISC}
  136.   lsOverrun  = $0001;
  137.   lsParity   = $0002;
  138.   lsFraming  = $0004;
  139.   lsBreak    = $0008;
  140.  
  141.   {Line and driver errors, duplicated from OOMISC}
  142.   leNoError    = 0;   {No error, ordinal value matches ecOK}
  143.   leBuffer     = 1;   {Buffer overrun in COMM.DRV}
  144.   leOverrun    = 2;   {UART receiver overrun}
  145.   leParity     = 3;   {UART receiver parity error}
  146.   leFraming    = 4;   {UART receiver framing error}
  147.   leCTSTO      = 5;   {Transmit timeout waiting for CTS}
  148.   leDSRTO      = 6;   {Transmit timeout waiting for DSR}
  149.   leDCDTO      = 7;   {Transmit timeout waiting for RLSD}
  150.   leTxFull     = 8;   {Transmit queue is full}
  151.   leBreak      = 9;   {Break condition received}
  152.  
  153.   {Status trigger subtypes, duplicated from OOMISC}
  154.   stNone        = 0;  {not active}
  155.   stModem       = 1;  {Trigger on modem status change}
  156.   stLine        = 2;  {Trigger on line status change}
  157.   stOutBuffFree = 3;  {Trigger on outbuff free level}
  158.   stOutBuffUsed = 4;  {Trigger on outbuff used level}
  159.   stOutSent     = 5;  {Trigger on any PutXxx call}
  160.  
  161.   {Parity strings}
  162.   ParityName : array[TParity] of String[5] =
  163.     ('None', 'Odd', 'Even', 'Mark', 'Space');
  164.  
  165.   {Property defaults}
  166.   DefDeviceLayer = dlComm;
  167.   DefComHandle = 0;
  168.   DefComNumber = 2;
  169.   DefBaud      = 19200;
  170.   DefParity    = pNone;
  171.   DefDatabits  = 8;
  172.   DefStopbits  = 1;
  173.   DefInSize    = 4096;
  174.   DefOutSize   = 4096;
  175.   DefOpen      = False;
  176.   DefAutoOpen  = True;
  177.   DefDispatcherMode = dTimer;
  178.   DefDTR       = True;
  179.   DefRTS       = True;
  180.   DefTracing   = tlOff;
  181.   DefTraceSize = 10000;
  182.   DefTraceName = 'APD.TRC';
  183.   DefTraceHex  = True;
  184.   DefLogging   = tlOff;
  185.   DefLogSize   = 10000;
  186.   DefLogName   = 'APD.LOG';
  187.   DefLogHex    = True;
  188.   DefUseMSRShadow = True;
  189.   DefForceGets = False;
  190.   DefUseEventWord = True;
  191.   DefHWFlowOptions = [];
  192.   DefSWFlowOptions = swfNone;
  193.   DefXonChar   = #17;
  194.   DefXoffChar  = #19;
  195.   DefBufferFull = 0;
  196.   DefBufferResume = 0;
  197.   DefTriggerLength = 1;
  198.   DefCommNotificationLevel = 10;
  199.  
  200. type
  201.   {.Z+}
  202.   {Baud rate property editor}
  203.   TBaudRateProperty = class(TIntegerProperty)
  204.   public
  205.     procedure Edit; override;
  206.     function GetAttributes: TPropertyAttributes; override;
  207.   end;
  208.   {.Z-}
  209.  
  210.   {Port component}
  211.   TApdCustomComPort = class(TComponent)
  212.   protected {private}
  213.     {.Z+}
  214.     {Internal stuff}
  215.     Force            : Boolean;             {True to force property setting}
  216.     TriggerHandler   : TNotifyProc;         {Internal trigger handler}
  217.     IsOpen           : Boolean;             {True if physically open}
  218.     OkToOpen         : Boolean;             {True if port was loaded}
  219.     ForceOpen        : Boolean;             {Force open after loading}
  220.     UserList         : TList;               {List of comport users}
  221.     CopyTriggers     : Boolean;             {Copy triggers on open}    {!!.01}
  222.     SaveTriggers     : TTriggerSave;        {Triggers to copy}         {!!.01}
  223.  
  224.     {Port info}
  225.     FDeviceLayer     : TDeviceLayer;        {Device layer for this port}
  226.     FComHandle       : TComHandle;          {Handle to comm object}
  227.     FComNumber       : Word;                {Com1 - ComWhatever}
  228.     FBaud            : LongInt;             {Baud rate}
  229.     FParity          : TParity;             {Parity}
  230.     FDatabits        : Word;                {Data bits}
  231.     FStopbits        : Word;                {Stop bits}
  232.     FInSize          : Word;                {Input buffer size}
  233.     FOutSize         : Word;                {Output buffer size}
  234.     FOpen            : Boolean;             {True if the port is open}
  235.     FAutoOpen        : Boolean;             {True to do implicit opens}
  236.     FDispatcherMode  : TDispatcherMode;     {Dispatcher mode}
  237.     FActivateDevice  : TActivationProcedure; {Proc to activate device layer}
  238.     FCommNotificationLevel : Word;          {Comm notify level}
  239.  
  240.     {Modem control/status}
  241.     FDTR             : Boolean;             {DTR control state}
  242.     FRTS             : Boolean;             {RTS control state}
  243.  
  244.     {Flow control}
  245.     FBufferFull      : Word;                {Flow control cutoff}
  246.     FBufferResume    : Word;                {Flow control resume}
  247.     FHWFlowOptions   : THWFlowOptionSet;    {Hardware flow control}
  248.     FSWFlowOptions   : TSWFlowOptions;      {Software flow control}
  249.     FXOnChar         : Char;                {Xon character}
  250.     FXOffChar        : Char;                {Xoff character}
  251.  
  252.     {Debugging}
  253.     FTracing         : TTraceLogState;      {Controls Tracing state}
  254.     FTraceSize       : Word;                {Number of tracing entries}
  255.     FTraceName       : String;              {Name of trace file}
  256.     FTraceHex        : Boolean;             {True to dump trace in hex}
  257.     FLogging         : TTraceLogState;      {Controls DispatchLogging state}
  258.     FLogSize         : Word;                {Size, in bytes, of log buffer}
  259.     FLogName         : String;              {Name of log file}
  260.     FLogHex          : Boolean;             {True to dump log in hex}
  261.  
  262.     {Options}
  263.     FUseMSRShadow    : Boolean;             {True to use MSR shadow reg}
  264.     FForceGets       : Boolean;             {True to force GetChar to get}
  265.     FUseEventWord    : Boolean;             {True to use the EventWord}
  266.  
  267.     {Triggers}
  268.     FTriggerLength   : Word;                {Number of byte for avail trigger}
  269.     FOnTrigger       : TTriggerEvent;       {All-encompassing event handler}
  270.     FOnTriggerAvail  : TTriggerAvailEvent;  {APW_TRIGGERAVAIL events}
  271.     FOnTriggerData   : TTriggerDataEvent;   {APW_TRIGGERDATA events}
  272.     FOnTriggerStatus : TTriggerStatusEvent; {APW_TRIGGERSTATUS events}
  273.     FOnTriggerTimer  : TTriggerTimerEvent;  {APW_TRIGGERTIMER events}
  274.     FOnTriggerLineError   : TTriggerLineErrorEvent;  {Got line error}
  275.     FOnTriggerModemStatus : TNotifyEvent;   {Got modem status change}
  276.     FOnTriggerOutbuffFree : TNotifyEvent;   {Outbuff free above mark}
  277.     FOnTriggerOutbuffUsed : TNotifyEvent;   {Outbuff used above mark}
  278.     FOnTriggerOutSent     : TNotifyEvent;   {Data was transmitted}
  279.     FOnPortOpen      : TNotifyEvent;        {Port just opened}
  280.     FOnPortClose     : TNotifyEvent;        {Port just closed}
  281.     FOnWaitChar      : TWaitCharEvent;      {Received char during wait}
  282.  
  283.     {Property read/write methods}
  284.     procedure SetDeviceLayer(const NewDevice : TDeviceLayer);
  285.     procedure SetComNumber(const NewNumber : Word);
  286.     procedure SetBaud(const NewBaud : Longint);
  287.     procedure SetParity(const NewParity : TParity);
  288.     procedure SetDatabits(const NewBits : Word);
  289.     procedure SetStopbits(const NewBits : Word);
  290.     procedure SetInSize(const NewSize : Word);
  291.     procedure SetOutSize(const NewSize : Word);
  292.     procedure SetTracing(const NewState : TTraceLogState);
  293.     procedure SetTraceSize(const NewSize : Word);
  294.     procedure SetLogging(const NewState : TTraceLogState);
  295.     procedure SetLogSize(const NewSize : Word);
  296.     procedure SetOpen(const Enable : Boolean);
  297.     procedure SetDispatcherMode(const NewMode : TDispatcherMode);
  298.     procedure SetHWFlowOptions(const NewOpts : THWFlowOptionSet);
  299.     function GetFlowState : TFlowControlState;
  300.     procedure SetSWFlowOptions(const NewOpts : TSWFlowOptions);
  301.     procedure SetXonChar(const NewChar : Char);
  302.     procedure SetXoffChar(const NewChar : Char);
  303.     procedure SetBufferFull(const NewFull : Word);
  304.     procedure SetBufferResume(const NewResume : Word);
  305.     procedure SetTriggerLength(const NewLength : Word);
  306.     procedure SetDTR(const NewDTR : Boolean);
  307.     procedure SetRTS(const NewRTS : Boolean);
  308.     function GetComHandle : TComHandle;
  309.     function GetModemStatus : Byte;
  310.     function GetDSR : Boolean;
  311.     function GetCTS : Boolean;
  312.     function GetRI : Boolean;
  313.     function GetDCD : Boolean;
  314.     function GetDeltaDSR : Boolean;
  315.     function GetDeltaCTS : Boolean;
  316.     function GetDeltaRI : Boolean;
  317.     function GetDeltaDCD : Boolean;
  318.     function GetLineError : Word;
  319.     function GetLineBreak : Boolean;
  320.     function GetInBuffUsed : Word;
  321.     function GetInBuffFree : Word;
  322.     function GetOutBuffUsed : Word;
  323.     function GetOutBuffFree : Word;
  324.     procedure SetUseMSRShadow(NewUse : Boolean);
  325.     procedure SetForceGets(NewForce : Boolean);
  326.     procedure SetUseEventWord(NewUse : Boolean);
  327.     procedure SetCommNotificationLevel(NewLevel : Word);
  328.  
  329.   protected
  330.     {Misc}
  331.     procedure Loaded; override;
  332.  
  333.     {Trigger event methods}
  334.     procedure Trigger(Msg, TriggerHandle, Data : Word); virtual;
  335.     procedure TriggerAvail(Count : Word); virtual;
  336.     procedure TriggerData(TriggerHandle : Word); virtual;
  337.     procedure TriggerStatus(TriggerHandle : Word); virtual;
  338.     procedure TriggerTimer(TriggerHandle : Word); virtual;
  339.  
  340.     {Port open/close/change event methods}
  341.     procedure PortOpen; dynamic;
  342.     procedure PortClose; dynamic;
  343.  
  344.     {Status trigger methods}
  345.     procedure TriggerLineError(const Error : Word;
  346.                                const LineBreak : Boolean); virtual;
  347.     procedure TriggerModemStatus; virtual;
  348.     procedure TriggerOutbuffFree; virtual;
  349.     procedure TriggerOutbuffUsed; virtual;
  350.     procedure TriggerOutSent; virtual;
  351.  
  352.     {Wait trigger method}
  353.     procedure WaitChar(C : Char); virtual;
  354.  
  355.     {Tracing}
  356.     procedure InitTracing(const NumEntries : Word);
  357.     procedure DumpTrace(const FName : String; const InHex : Boolean);
  358.     procedure AppendTrace(const FName : String; const InHex : Boolean);
  359.     procedure ClearTracing;
  360.     procedure AbortTracing;
  361.     procedure StartTracing;
  362.     procedure StopTracing;
  363.  
  364.     {DispatchLogging}
  365.     procedure InitLogging(const Size : Word);
  366.     procedure DumpLog(const FName : String; const InHex : Boolean);
  367.     procedure AppendLog(const FName : String; const InHex : Boolean);
  368.     procedure ClearLogging;
  369.     procedure AbortLogging;
  370.     procedure StartLogging;
  371.     procedure StopLogging;
  372.  
  373.   public
  374.     {Creation/destruction}
  375.     constructor Create(AOwner : TComponent); override;
  376.       {-Create a TApdComPort component}
  377.     destructor Destroy; override;
  378.       {-Destroy a TApdComPort component}
  379.  
  380.     {General}
  381.     procedure InitPort; dynamic;
  382.       {-Physically open the serial port}
  383.     procedure DonePort; dynamic;
  384.       {-Physically close the serial port}
  385.     procedure Assign(Source: TPersistent); override;
  386.       {-Assign fields from TApdComPort object specified by Source}
  387.     procedure ForcePortOpen;
  388.       {-Force the port open after it is loaded}
  389.     procedure SendBreak(Ticks : Word; Yield : Boolean);
  390.       {-Send a line break of ticks duration}
  391.  
  392.     {.Z-}
  393.     procedure RegisterUser(const H : THandle);
  394.       {-Register a TApdComPort user to receive PortOpen/PortClose events}
  395.     procedure RegisterUserCallback(CallBack : TPortCallback);          {!!.01}
  396.       {-Register a TApdComPort user to receive callbacks}              {!!.01}
  397.     procedure DeregisterUser(const H : THandle);
  398.       {-Deregister a TApdComPort user from receiving PortOpen/PortClose events}
  399.     procedure DeregisterUserCallback(CallBack : TPortCallback);        {!!.01}
  400.       {-Deregister a TApdComPort user callback}                        {!!.01}
  401.     procedure ProcessCommunications; virtual;
  402.       {-Call the internal dispatcher}
  403.     procedure FlushInBuffer;
  404.       {-Discard the contents of the input buffer}
  405.     procedure FlushOutBuffer;
  406.       {-Discard the contents of the output buffer}
  407.     procedure RegisterTriggerHandler(H : HWnd; NP : TNotifyProc);
  408.       {-Register a window or TNotifyProc as a recipient of trigger messages}
  409.     procedure DeregisterTriggerHandler(H : HWnd; NP : TNotifyProc);
  410.       {-Deregister a trigger handler}
  411.  
  412.     {Trigger managment}
  413.     function AddDataTrigger(const Data : ShortString;                  {!!.01}
  414.                             const IgnoreCase : Boolean) : Word;
  415.       {-Add a data trigger}
  416.     function AddTimerTrigger : Word;
  417.       {-Add a timer trigger}
  418.     function AddStatusTrigger(const SType : Word) : Word;
  419.       {-Add a status trigger}
  420.     procedure RemoveTrigger(const Handle : Word);
  421.       {-Remove a trigger}
  422.     procedure RemoveAllTriggers;
  423.       {-Remove all triggers}
  424.     procedure SetTimerTrigger(const Handle : Word; const Ticks : LongInt;
  425.                               const Activate : Boolean);
  426.       {-Activate or deactivate a timer trigger}
  427.     procedure SetStatusTrigger(const Handle : Word; const Value : Word;
  428.                                const Activate : Boolean);
  429.       {-Activate or deactivate a status trigger}
  430.  
  431.     {I/O}
  432.     function CharReady : Boolean;
  433.       {-Return True if at least one character is in the input buffer}
  434.     function PeekChar(const Count : Word) : Char;
  435.       {-Return a received character other than the next one}
  436.     function GetChar : Char;
  437.       {-Return the next received character}
  438.     procedure PeekBlock(var Block; const Len : Word);
  439.       {-Return a block of data other than the next block}
  440.  
  441.     procedure GetBlock(var Block; const Len : Word);
  442.       {-Return the next block of data}
  443.     procedure PutChar(const C : Char);
  444.       {-Add C to the output buffer}
  445.     procedure PutString(const S : String);
  446.       {-Add S to the output buffer}
  447.     function PutBlock(const Block; const Len : Word) : Integer;
  448.       {-Add Block to the output buffer}
  449.  
  450.     {Waits}
  451.     function CheckForString(var Index : Byte; C : Char;
  452.                             const S : String;
  453.                             IgnoreCase : Boolean) : Boolean;
  454.       {-Compare C against a sequence of chars, looking for S}
  455.     function WaitForString(const S : String;
  456.                            const Timeout : LongInt;
  457.                            const Yield, IgnoreCase : Boolean) : Boolean;
  458.       {-Wait for S}
  459.     function WaitForMultiString(const S : String; const Timeout : LongInt;
  460.                                 const Yield, IgnoreCase : Boolean;
  461.                                 const SepChar : Char) : Integer;
  462.       {-Wait for S, which contains several substrings separated by ^}
  463.  
  464.     {Port parameter properties}
  465.     property DeviceLayer : TDeviceLayer
  466.       read FDeviceLayer write SetDeviceLayer default DefDeviceLayer;
  467.     property ComNumber : Word
  468.       read FComNumber write SetComNumber default DefComNumber;
  469.     property Baud : LongInt
  470.       read FBaud write SetBaud default DefBaud;
  471.     property Parity : TParity
  472.       read FParity write SetParity default DefParity;
  473.     property DataBits : Word
  474.       read FDatabits write SetDatabits default DefDatabits;
  475.     property StopBits : Word
  476.       read FStopbits write SetStopbits default DefStopbits;
  477.  
  478.     {Miscellaneous port properties}
  479.     property InSize : Word
  480.       read FInSize write SetInSize default DefInSize;
  481.     property OutSize : Word
  482.       read FOutSize write SetOutSize default DefOutSize;
  483.     property Open : Boolean
  484.       read FOpen write SetOpen default DefOpen;
  485.     property AutoOpen : Boolean
  486.       read FAutoOpen write FAutoOpen default DefAutoOpen;
  487.     property DispatcherMode : TDispatcherMode
  488.       read FDispatcherMode write SetDispatcherMode default DefDispatcherMode;
  489.     property CommNotificationLevel : Word
  490.       read FCommNotificationLevel write SetCommNotificationLevel
  491.       default DefCommNotificationLevel;
  492.  
  493.     {Modem control/status}
  494.     property DTR : Boolean
  495.       read FDTR write SetDTR default DefDTR;
  496.     property RTS : Boolean
  497.       read FRTS write SetRTS default DefRTS;
  498.  
  499.     {Flow control properties}
  500.     property HWFlowOptions : THWFlowOptionSet
  501.       read FHWFlowOptions write SetHWFlowOptions default DefHWFlowOptions;
  502.     property FlowState : TFlowControlState
  503.       read GetFlowState;
  504.     property SWFlowOptions : TSWFlowOptions
  505.       read FSWFlowOptions write SetSWFlowOptions default DefSWFlowOptions;
  506.     property XOnChar : Char
  507.       read FXonChar write SetXonChar default DefXOnChar;
  508.     property XOffChar : Char
  509.       read FXOffChar write SetXoffChar default DefXOffChar;
  510.     property BufferFull : Word
  511.       read FBufferFull write SetBufferFull default DefBufferFull;
  512.     property BufferResume : Word
  513.       read FBufferResume write SetBufferResume default DefBufferResume;
  514.  
  515.     {Debugging}
  516.     property Tracing : TTraceLogState
  517.       read FTracing write SetTracing default DefTracing;
  518.     property TraceSize : Word
  519.       read FTraceSize write SetTraceSize default DefTraceSize;
  520.     property TraceName : String
  521.       read FTraceName write FTraceName;
  522.     property TraceHex : Boolean
  523.       read FTraceHex write FTraceHex default DefTraceHex;
  524.     property Logging : TTraceLogState
  525.       read FLogging write SetLogging default DefLogging;
  526.     property LogSize : Word
  527.       read FLogSize write SetLogSize default DefLogSize;
  528.     property LogName : String
  529.       read FLogName write FLogName;
  530.     property LogHex : Boolean
  531.       read FLogHex write FLogHex default DefLogHex;
  532.  
  533.     {Options}
  534.     property UseMSRShadow : Boolean
  535.       read FUseMSRShadow write SetUseMSRShadow default DefUseMSRShadow;
  536.     property ForceGets : Boolean
  537.       read FForceGets write SetForceGets default DefForceGets;
  538.     property UseEventWord : Boolean
  539.       read FUseEventWord write SetUseEventWord default DefUseEventWord;
  540.  
  541.     {Tracing}
  542.     procedure AddTraceEntry(const CurEntry, CurCh : Char);
  543.       {-Add an entry to the trace buffer}
  544.  
  545.     {Trigger events}
  546.     property TriggerLength : Word
  547.       read FTriggerLength write SetTriggerLength default DefTriggerLength;
  548.     property OnTrigger : TTriggerEvent
  549.       read FOnTrigger write FOnTrigger;
  550.     property OnTriggerAvail : TTriggerAvailEvent
  551.       read FOnTriggerAvail write FOnTriggerAvail;
  552.     property OnTriggerData : TTriggerDataEvent
  553.       read FOnTriggerData write FOnTriggerData;
  554.     property OnTriggerStatus : TTriggerStatusEvent
  555.       read FOnTriggerStatus write FOnTriggerStatus;
  556.     property OnTriggerTimer : TTriggerTimerEvent
  557.       read FOnTriggerTimer write FOnTriggerTimer;
  558.  
  559.     {.Z+}
  560.     {Port open/close/change events}
  561.     property OnPortOpen : TNotifyEvent
  562.       read FOnPortOpen write FOnPortOpen;
  563.     property OnPortClose : TNotifyEvent
  564.       read FOnPortClose write FOnPortClose;
  565.     {.Z-}
  566.  
  567.     {Status events}
  568.     property OnTriggerLineError : TTriggerLineErrorEvent
  569.       read FOnTriggerLineError write FOnTriggerLineError;
  570.     property OnTriggerModemStatus : TNotifyEvent
  571.       read FOnTriggerModemStatus write FOnTriggerModemStatus;
  572.     property OnTriggerOutbuffFree : TNotifyEvent
  573.       read FOnTriggerOutbuffFree write FOnTriggerOutbuffFree;
  574.     property OnTriggerOutbuffUsed : TNotifyEvent
  575.       read FOnTriggerOutbuffUsed write FOnTriggerOutbuffUsed;
  576.     property OnTriggerOutSent : TNotifyEvent
  577.       read FOnTriggerOutSent write FOnTriggerOutSent;
  578.  
  579.     {WaitChar event}
  580.     property OnWaitChar : TWaitCharEvent
  581.       read FOnWaitchar write FOnWaitChar;
  582.  
  583.     {Device layer activation property}
  584.     property ActivateDevice : TActivationProcedure
  585.       read FActivateDevice write FActivateDevice;
  586.  
  587.     {I/O properties}
  588.     property Output : String
  589.       write PutString;
  590.  
  591.     {TComHandle, read only}
  592.     property ComHandle : Word
  593.       read GetComHandle default DefComHandle;
  594.  
  595.     {Modem status, read only}
  596.     property ModemStatus : Byte
  597.       read GetModemStatus;
  598.     property DSR : Boolean
  599.       read GetDSR;
  600.     property CTS : Boolean
  601.       read GetCTS;
  602.     property RI : Boolean
  603.       read GetRI;
  604.     property DCD : Boolean
  605.       read GetDCD;
  606.     property DeltaDSR : Boolean
  607.       read GetDeltaDSR;
  608.     property DeltaCTS : Boolean
  609.       read GetDeltaCTS;
  610.     property DeltaRI : Boolean
  611.       read GetDeltaRI;
  612.     property DeltaDCD : Boolean
  613.       read GetDeltaDCD;
  614.  
  615.     {Line errors}
  616.     property LineError : Word
  617.       read GetLineError;
  618.     property LineBreak : Boolean
  619.       read GetLineBreak;
  620.  
  621.     {Buffer info, readonly}
  622.     property InBuffUsed : Word
  623.       read GetInBuffUsed;
  624.     property InBuffFree : Word
  625.       read GetInBuffFree;
  626.     property OutBuffUsed : Word
  627.       read GetOutBuffUsed;
  628.     property OutBuffFree : Word
  629.       read GetOutBuffFree;
  630.   end;
  631.  
  632.   {Port component}
  633.   TApdComPort = class(TApdCustomComPort)
  634.   published
  635.     property DeviceLayer;
  636.     property ComNumber;
  637.     property Baud;
  638.     property Parity;
  639.     property DataBits;
  640.     property StopBits;
  641.     property InSize;
  642.     property OutSize;
  643.     property AutoOpen;
  644.     property DispatcherMode;
  645.     property Open;
  646.     property DTR;
  647.     property RTS;
  648.     property HWFlowOptions;
  649.     property SWFlowOptions;
  650.     property XOnChar;
  651.     property XOffChar;
  652.     property BufferFull;
  653.     property BufferResume;
  654.     property Tracing;
  655.     property TraceSize;
  656.     property TraceName;
  657.     property TraceHex;
  658.     property Logging;
  659.     property LogSize;
  660.     property LogName;
  661.     property LogHex;
  662.     property UseMSRShadow;
  663.     property ForceGets;
  664.     property UseEventWord;
  665.     property TriggerLength;
  666.     property CommNotificationLevel;
  667.     property OnTrigger;
  668.     property OnTriggerAvail;
  669.     property OnTriggerData;
  670.     property OnTriggerStatus;
  671.     property OnTriggerTimer;
  672.     property OnTriggerLineError;
  673.     property OnTriggerModemStatus;
  674.     property OnTriggerOutbuffFree;
  675.     property OnTriggerOutbuffUsed;
  676.     property OnTriggerOutSent;
  677.     property OnWaitChar;
  678.     property Tag;
  679.   end;
  680.  
  681.   function ErrorMsg(const ErrorCode : SmallInt) : String;
  682.   function ComName(const ComNumber : Word) : String;
  683.   {.Z+}
  684.   function SearchComPort(const C : TComponent) : TApdCustomComPort;
  685.   procedure Register;
  686.   {.Z-}
  687.  
  688.